<template>
    <div>
        <!--功能栏-->
        <div>
            <el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search"
                      v-model="userName"></el-input>

            <el-button type="primary" style="margin-left: 5px;" @click="searchDoc">搜索 <i
                class="el-icon-search"></i></el-button>
            <el-button type="primary" style="margin-left: 5px;" @click="refresh">刷新 <i class="el-icon-refresh"></i>
            </el-button>
        </div>
    </div>
</template>

<script>
export default {
    name: "DocumentToolbar",
    data() {
        return {
            userName: '',
            // delTag: 1,
            /****************新建文档**************************/
        }
    },
    props: {
        pageNum: Number,
        pageSize: Number,
        delTag: Number
    },
    methods: {
        //根据关键字搜索文档
        searchDoc() {
            this.axios.get('/back_system_user/selectUserByPage', {
                //参数
                params: {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                    userName: this.userName,
                    delTag: this.delTag
                }
            })
                .then(response => {
                    console.log(response.data)
                    let data = response.data.data.userList
                    let total = response.data.data.total
                    // 触发自定义事件，将获取到的数据传递给父组件给父组件
                    this.$emit('search', data);
                    this.$emit('search-total', total)
                })
                .catch(error => {
                    console.log(error)
                    this.$message.error("错误")
                })
        },

        //刷新页面
        refresh() {
            location.reload()
        },
    }
}
</script>

<style scoped>

</style>
